package com.shujia.wyh.day13.ketang;

/*
        老师案例
        具体事物：十六期老师，十六期老师
        共性：姓名，年龄，讲课。

        分析：
            1、十六期老师：
                属性：姓名，年龄
                行为：讲课（Hive）
              十七期老师：
                属性：姓名，年龄
                行为：讲课（Java）
       向上提取一个抽象父类：Teacher
            Teacher:
                成员变量：name,age
                成员方法：teach();(抽象方法)
 */
abstract class Teacher{
    private String name;
    private int age;

    public Teacher() {
    }

    public Teacher(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //抽象的讲课方法
    public abstract void teach();
}

class SixteenTeacher extends Teacher{
    public SixteenTeacher() {
    }

    public SixteenTeacher(String name, int age) {
        super(name, age);
    }

    @Override
    public void teach() {
        System.out.println("十六期老师讲解hive");
    }
}

class SeventeenTeacher extends Teacher{
    public SeventeenTeacher() {
    }

    public SeventeenTeacher(String name, int age) {
        super(name, age);
    }

    @Override
    public void teach() {
        System.out.println("十七期老师讲解java");
    }
}


public class AbstractTest1 {
    public static void main(String[] args) {
        //创建一个十六期老师
        Teacher t1 = new SixteenTeacher("志凯",17);
        t1.teach();

        //创建一个十七老师
        Teacher t2 = new SeventeenTeacher("小虎",15);
        t2.teach();
    }
}
